//
//  VideoPlayController.m
//  Channel
//
//  Created by CPX on 2018/9/6.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "VideoPlayController.h"
#import <WebKit/WebKit.h>

/**
 视频播放页
 @author yzl
 */
@interface VideoPlayController ()<WKNavigationDelegate>

@property (nonatomic, strong) WKWebView *webView;

@end

@implementation VideoPlayController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)initViews{
    self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, NavHeight, kScreenWidth, kScreenHeight-NavHeight)];
    self.webView.navigationDelegate = self;
    [self.view addSubview:self.webView];
}

- (void)initNavigation{
    [self initDefaultNavigation];
}

- (void)loadData{
    [MBProgressTool showLoadingForView:self.view];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
    [self.webView loadRequest:request];
}

#pragma mark - webview

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
    NSLog(@"load success");
    [MBProgressTool hideForView:self.view];
}

- (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
    NSLog(@"load error");
    [MBProgressTool showTextForView:self.view text:@"Load Video Failure"];
}

@end
